/**
 * \file	CodeGenerator.h
 * \author	Caio Arce Nishibe (caionishibe@gmail.com)
 * \date	August, 2014
 * \brief	Code Generator header.
 */


#ifndef __CODE_GENERATOR_H
#define __CODE_GENERATOR_H

#include "IVisitor.h"
#include <iostream>
#include <fstream>
#include <limits>

using namespace std;

/**
 * \brief	C Code Generator.
 * \details	Implements the IVisitor interface.
 * \author	Caio Arce Nishibe (caionishibe@gmail.com)
 * \date	August, 2014
 */
class CodeGenerator : public IVisitor
{
private:
	/**
	 * \brief	Output file
	 */
	ofstream generatedCodeFile;

public:
	/**
	 * \brief	CodeGenerator constructor.	
	 * \brief	Create an output file with a given name.
	 * \param	filename	output file name.
	 */
	CodeGenerator(string filename);
	
	/**
	 * \brief CodeGenerator destructor.
	 */
	~CodeGenerator();


	void VisitProgram(ASTNode *node);
	void VisitName(ASTNode *node);
	void VisitVariable(ASTNode *node);
	void VisitRules(ASTNode *node);
	void VisitRulesSet(ASTNode *node);
	void VisitRule(ASTNode *node);
	void VisitCondition(ASTNode *node);
	void VisitLogicOperator(ASTNode *node);
	void VisitInternalCondition(ASTNode *node);
	void VisitComparationOperator(ASTNode *node);
	void VisitArithmeticOperator(ASTNode *node);
	void VisitArithmeticExpression(ASTNode *node);
	void VisitAction(ASTNode * node);
	void VisitCommand(ASTNode * node);;
	void VisitCmd(ASTNode *node);
	void VisitAssignment(ASTNode *node);
	void VisitReadSensor(ASTNode *node);
	void VisitWriteActuator(ASTNode *node);
	void VisitIdentifier(ASTNode *node);
	void VisitNumber(ASTNode *node);
	void VisitMessage(ASTNode *node);
};

#endif